package com.koron.device.service.impl;

import com.koron.device.bean.po.EquipmentCode;
import com.koron.device.mapper.EquipmentCodeMapper;
import com.koron.device.service.EquipmentCodeService;
import lombok.extern.slf4j.Slf4j;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class EquipmentCodeServiceImpl implements EquipmentCodeService {


    @TaskAnnotation("save")
    @Override
    public Boolean save(SessionFactory sessionFactory, List<EquipmentCode> equipmentCodes) {
        EquipmentCodeMapper equipmentCodeMapper = sessionFactory.getMapper(EquipmentCodeMapper.class);
        int result = equipmentCodeMapper.save(equipmentCodes);
        return result > 0;
    }

    @TaskAnnotation("get")
    @Override
    public List<String> get(SessionFactory sessionFactory,String equipmentId) {
        EquipmentCodeMapper equipmentCodeMapper = sessionFactory.getMapper(EquipmentCodeMapper.class);
        return equipmentCodeMapper.get(equipmentId);
    }

    @TaskAnnotation("getInfo")
    @Override
    public List<EquipmentCode> getInfo(SessionFactory sessionFactory, String equipmentId) {
        EquipmentCodeMapper equipmentCodeMapper = sessionFactory.getMapper(EquipmentCodeMapper.class);
        return equipmentCodeMapper.getInfo(equipmentId);
    }
}
